/*
 * Check the calculations for the power consumption average and resource capability and correct and applicable with respect to the
 * power consumption formulae in the resource class.
 */
public class ServerUsageData implements IServerUsageData
{
	private Double powerAverage = new Double(0.0);
	private Double serverCapability = new Double(1.0);
	private int internalCounter = 0;
	
	public ServerUsageData(Double pA, Double rC)
	{
		powerAverage = pA;
		serverCapability = rC;
		internalCounter = 1;
	}
	
	public Double getPowerAverage()
	{
		return powerAverage;
	}
	
	public Double getServerCapability()
	{
		return serverCapability;
	}
	
	public void adjustPowerAverage(Double newPowerConsumption)
	{
		Double prevPowerAverage = powerAverage;
		powerAverage = ((powerAverage*internalCounter) + newPowerConsumption)/(++internalCounter);
		
		setServerCapability(prevPowerAverage,powerAverage);
	}
	
	private void setServerCapability(Double prevPA, Double newPA)
	{
		serverCapability = newPA/prevPA;
	}
}
